﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WL_Store.BLL;
using WL_Store.Model;

namespace WL_Store.Web.subpage
{
    public partial class System_Logs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                BindPerList();
                BindSysLogs();
            }
        }

        protected void lbt_del_Command(object sender, CommandEventArgs e)
        {

        }

        private void BindSysLogs()
        {
            SystemLogsBLL bll = new SystemLogsBLL();
            string comName = txt_comName.Value.Trim();
            DateTime? StarttradingHour = null;
            if (!string.IsNullOrWhiteSpace(txt_StarttradingHour.Value.Trim()))
            {
                StarttradingHour = Convert.ToDateTime(txt_StarttradingHour.Value.Trim());
            }

            DateTime? EndtradingHour = null;
            if (!string.IsNullOrWhiteSpace(txt_EndtradingHour.Value.Trim()))
            {
                EndtradingHour = Convert.ToDateTime(txt_EndtradingHour.Value.Trim());
            }
            int gradeId = Convert.ToInt32(this.ddl_category.SelectedValue);

            SystemLogsSearchModel model = new SystemLogsSearchModel { 
            name=comName,
            StartTime=StarttradingHour,
            EndTime=EndtradingHour,
            GradeId=gradeId

            };
            List<SystemLogsModel> list= bll.GetSystems(model);
            rpt_systemlogs.DataSource = list;
            rpt_systemlogs.DataBind();

        }

        private void BindPerList()
        {
            SystemLogsBLL bll= new SystemLogsBLL();
            //读取权限信息
            DataTable dd = bll.PermissionInfo();
            //数据源赋值
            ddl_category.DataSource = dd;

            //显示字段
            ddl_category.DataTextField = "Grade";

            //值字段
            ddl_category.DataValueField = "GradeId";

            //绑定
            ddl_category.DataBind();


            ddl_category.Items.Insert(0, new ListItem("全部", "0"));
        }

        protected void btn_searchs_Click(object sender, EventArgs e)
        {
            BindSysLogs();
        }
    }
}